<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH. 'controllers/layout.php');

class Products extends Layout
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function index()
	{
		$config['per_page'] = 8;
		if($this->input->post('search')){
			$search = $this->input->post('search');
			$page = 0;
		}else{
			$search = $this->input->get('search');
		}
		$page = $this->uri->segment(2);
	
		$result = $this->product_model->getAllSearchProduct($search, $page, $config['per_page']);

		$this->load->library('pagination');
		
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		
		$config['first_link'] = 'Trang đầu';
		$config['last_link'] = 'Trang sau';
		
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
		
		$data['tbl_products'] = $result['tbl_products'];
		
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['meta'] = $this->load->view('home/meta', '', TRUE);
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
		
		), true);
		
// 		/$this->_data['seo'] = "demo";
		$this->load->view('home/layout_view', $this->_data);
	}
	
	public function index1()
	{
		$config['per_page'] = 6;
		if($this->input->post('search')){
			$search = $this->input->post('search');
			$page = 0;
		}else{
			$search = $this->input->get('search');
		}
		$page = $this->uri->segment(2);
	
		$result = $this->product_model->getAllSearchProductt($search, $page, $config['per_page']);
	
		$this->load->library('pagination');
	
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi-t';
		$config['total_rows'] = $result['total_record'];
		
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	
	public function aprice()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchProductPrice($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		//echo $result['sql'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
		
		$data['tbl_products'] = $result['tbl_products'];
		
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	public function origin()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchProductorigin($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		//echo $result['sql'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
				
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	public function brand()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchProductbrand($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		//echo $result['sql'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
	
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	
	public function capacity()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchProductcapacity($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		//echo $result['sql'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
	
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
    
    
    
    public function features()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchProductfeatures($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		//echo $result['sql'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
        $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		$this->_data['main_container'] = $this->load->view('home/allproducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
	
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	
	public function category()
	{
		
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchCategory($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
         $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		
		$detaildichvu = $this->utility_model->getDetail('tbl_category', 'cate_id',$param['id']);
		
		$this->_data['seo'] = array(
				'metakey' => $detaildichvu->metakey,
				'metades' => $detaildichvu->metades,
		);
		$this->_data['main_container'] = $this->load->view('home/allproductsCate_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                 'tinhnang' => $tinhnang,
				'pagination' => $data["paging"],
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	
	public function deproduct()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchCategory($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
         $tinhnang = $this->utility_model->selectStatus('tbl_technology');
		
		$detailproduct = $this->product_model->getDetail($this->uri->segment(1));
		
		$this->_data['seo'] = array(
			'metakey' => $detailproduct->metakey,
			'metades' => $detailproduct->metades,
		);
		
		$this->_data['main_container'] = $this->load->view('home/detailProducts_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'tinhnang' => $tinhnang,
				'detailproduct' => $detailproduct,
				'pagination' => $data["paging"],
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	
	
	public function checkout()
	{
		$param = $this->uri->ruri_to_assoc();
		$search = $param['id'];
		$config['per_page'] = 20;
		$page = $this->uri->segment(2);
		$result = $this->product_model->getAllSearchCategory($search, $page, $config['per_page']);
		$this->load->library('pagination');
		$config['base_url'] = base_url().'/dieu-hoa-khong-khi';
		$config['total_rows'] = $result['total_record'];
		if($search != ''){
			$this->pagination->suffix = '?search='. $search;
		}
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
	
		$data['tbl_products'] = $result['tbl_products'];
	
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
         $tinhnang = $this->utility_model->selectStatus('tbl_technology');
	
		$detailproduct = $this->product_model->getDetailProduct($param['id']);
	
	
		$this->_data['main_container'] = $this->load->view('home/checkout_view', array(
				'tbl_products' => $data['tbl_products'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                 'tinhnang' => $tinhnang,
				'detailproduct' => $detailproduct,
				'pagination' => $data["paging"],
		), true);
		$this->load->view('home/layout_view', $this->_data);
	}
	

	
}